package Task19;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()){
            int n = scanner.nextInt();
            if(n == 0){
                return;
            }
            //记录每次能换多少饮料
            int sum = 0;
            //记录能喝的饮料
            int drink = 0;
            while( n > 2){
                //记录每次能换多少瓶饮料
                sum = n/3;
                //记录每次能喝多少瓶饮料
                drink += sum;
                //将喝完的空瓶子喝兑换剩下来的空瓶子相加
                n = sum + n % 3;
            }
            //在剩余两个空瓶子时还能向老板借一个空瓶子
            if(n == 2){
                drink++;
            }
            System.out.println(drink);
        }
    }
}
